clear
clc

dataName = {'bbcnewssport_737n_1000d_5c_uni_12k', 'COIL20_1440n_1024d_20c_uni_12k',...
              'k1b_2340n_21839d_6c_tfidf_uni_12k',...
                'Lung_203n_3312d_5c_uni_12k', 'lymphoma_96n_4026d_9c_12k',...
                 'RELATHE_1427n_4322d_2c_tfidf_uni_12k', 'SMK_CAN_187n_19993d_2c_12k',...
                'TOX_171n_5748d_4c_zscore_12k', 'uspst_uni_12k'};     
addpath(fullfile(pwd, '..', 'lib'));
for i1 =1:length(dataName)
load(fullfile(pwd, '..', 'data', dataName{i1}));
numclass = length(unique(Y));
numker = size(Ks,3);
num = size(Ks,1);
Ks = kcenter(Ks);
Ks = knorm(Ks);
M = calculateM(Ks);
rhoset2 =2.^[-15:2:15];
lambdaset2 = 2.^[-15:2:15];
accval2 = zeros(length(rhoset2),length(lambdaset2));
nmival2 = zeros(length(rhoset2),length(lambdaset2));
purval2 = zeros(length(rhoset2),length(lambdaset2));
ts = zeros(length(rhoset2),length(lambdaset2));
res_onmkc_aio=[];
res_param=[];
for ir =1:length(rhoset2)
    for il = 1:length(lambdaset2)
        tic;
        [label_onmkc,H_normalized2,gamma2,G2,obj2] = myoptimalNeighborhoodkernelclustering(Ks,M,numclass,rhoset2(ir),lambdaset2(il));
        ts(ir, il) = toc;
         res_param=ClusteringMeasure(Y, label_onmkc)
         res_onmkc_aio = [res_onmkc_aio;res_param];
    end
end
res_onmkc = max(res_onmkc_aio, [], 1);
tsavg = mean(mean(ts));
save([dataName{i1}, '_onmkc_multi_kernel.mat'],  'res_onmkc','res_onmkc_aio');
end
